﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using TorchView.GameContent.Data;

namespace TorchView.GameContent.Effects
{
    public class Effect
    {
        public const string BLOCK_NAME = "EFFECT";

        public void LoadFromDataBlock(DataBlock block)
        {
            if (block == null)
                throw new ArgumentNullException("block");
            if (block.Name != BLOCK_NAME)
                throw new ArgumentException("Incorrect block type, only " + BLOCK_NAME + " is supported.");

            EffectName = block.GetPropertyValue("EFFECT", "");
            Name = block.GetPropertyValue("NAME", "");
            GoodDes = block.GetPropertyValue("GOODDES", "");
            GoodDesOT = block.GetPropertyValue("GOODDESOT", "");
            BadDes = block.GetPropertyValue("BADDES", "");
            BadDesOT = block.GetPropertyValue("BADDESOT", "");
            MinVal = block.GetPropertyValue("MINVAL", 0);
            MaxVal = block.GetPropertyValue("MAXVAL", 0);
            Value1 = block.GetPropertyValue("VALUE1", "");
            Value2 = block.GetPropertyValue("VALUE2", "");
            Value3 = block.GetPropertyValue("VALUE3", "");
            Value4 = block.GetPropertyValue("VALUE4", "");
            Value5 = block.GetPropertyValue("VALUE5", "");
            Graph1 = block.GetPropertyValue("GRAPH1", "");
            Graph2 = block.GetPropertyValue("GRAPH2", "");
            Type = block.GetPropertyValue("TYPE", "");
        }

        public Game.Effect CreateGameEffect()
        {
            Game.Effect gameEffect = new Game.Effect();
            gameEffect.RangeMin = MinVal;
            gameEffect.RangeMax = MaxVal;
            gameEffect.Bonus = MaxVal;
            gameEffect.Index = Index;
            return gameEffect;
        }

        #region Properties
        [DisplayName("Effect Name"), Category("Effect"), Description("Effect")]
        public string EffectName { get; set; }

        [DisplayName("Display Name"), Category("Effect"), Description("Effect Name")]
        public string Name { get; set; }

        [DisplayName("Good Description"), Category("Effect"), Description("Good Effect Description")]
        public string GoodDes { get; set; }

        [DisplayName("Good Description Over Time"), Category("Effect"), Description("Good Effect Description Over Time")]
        public string GoodDesOT { get; set; }

        [DisplayName("Bad Description"), Category("Effect"), Description("Bad Effect Description")]
        public string BadDes { get; set; }

        [DisplayName("Bad Description Over Time"), Category("Effect"), Description("Bad Effect Description Over Time")]
        public string BadDesOT { get; set; }

        [DisplayName("Minimum Value"), Category("Effect"), Description("")]
        public int MinVal { get; set; }

        [DisplayName("Maximum Value"), Category("Effect"), Description("")]
        public int MaxVal { get; set; }

        [DisplayName("Value 1"), Category("Effect"), Description("")]
        public string Value1 { get; set; }

        [DisplayName("Value 2"), Category("Effect"), Description("")]
        public string Value2 { get; set; }

        [DisplayName("Value 3"), Category("Effect"), Description("")]
        public string Value3 { get; set; }

        [DisplayName("Value 4"), Category("Effect"), Description("")]
        public string Value4 { get; set; }

        [DisplayName("Value 5"), Category("Effect"), Description("")]
        public string Value5 { get; set; }

        [DisplayName("Graphics 1"), Category("Effect"), Description("")]
        public string Graph1 { get; set; }

        [DisplayName("Graphics 2"), Category("Effect"), Description("")]
        public string Graph2 { get; set; }

        [DisplayName("Type"), Category("Effect"), Description("")]
        public string Type { get; set; }

        [DisplayName("Index"), Category("Effect"), Description("")]
        public int Index { get; set; }
        #endregion

        public override string ToString()
        {
            return Name;
        }
    }
}
